(function($) {
jQuery.fn.PositionFixed = function(location) {

	var isIe6=false; //is ie ? yes:ie no: not ie
	if($.browser.msie && parseInt($.browser.version)==6)
		isIe6=true;			
	
	var html= $('html');
	if (isIe6 && html.css('backgroundAttachment') !== 'fixed') {
		html.css('backgroundAttachment','fixed') 
    };

    var l=0;
    var t=0;
    
	return this.each(function() {
		var domThis=$(this)[0];
		var objThis=$(this);
		var loc;//层的绝对定位位置

		if(location==undefined || location.constructor == String){
			switch(location){
				case("rightbottom"):
					loc={right:"0px",bottom:"0px"};
				break;
				case("leftbottom"):
					loc={left:"0px",bottom:"0px"};
					break;	
				case("lefttop")://左上角
					loc={left:"0px",top:"0px"};
					break;
				case("righttop")://右上角
					loc={right:"0px",top:"0px"};
					break;
				case("middle")://居中
					var l=0;//居左
					var t=0;//居上
					var windowWidth,windowHeight;//窗口的高和宽
					//取得窗口的高和宽
					if (self.innerHeight) {
						windowWidth=self.innerWidth;
						windowHeight=self.innerHeight;
					}else if (document.documentElement&&document.documentElement.clientHeight) {
						windowWidth=document.documentElement.clientWidth;
						windowHeight=document.documentElement.clientHeight;
					} else if (document.body) {
						windowWidth=document.body.clientWidth;
						windowHeight=document.body.clientHeight;
					}
					l=windowWidth/2-$(this).width()/2;
					t=windowHeight/2-$(this).height()/2;
					loc={left:l+"px",top:t+"px"};
					break;
				case("topmiddle")://居中
					var l=0;//居左
					var t=0;//居上
					var windowWidth,windowHeight;//窗口的高和宽
					//取得窗口的高和宽
					if (self.innerHeight) {
						windowWidth=self.innerWidth;
						windowHeight=self.innerHeight;
					}else if (document.documentElement&&document.documentElement.clientHeight) {
						windowWidth=document.documentElement.clientWidth;
						windowHeight=document.documentElement.clientHeight;
					} else if (document.body) {
						windowWidth=document.body.clientWidth;
						windowHeight=document.body.clientHeight;
					}
					l=windowWidth/2-$(this).width()/2;
					t=0;
					loc={left:l+"px",top:t+"px"};
					break;
				default://默认为右下角
					loc={right:"0px",bottom:"0px"};
				break;		
			}
		}else{
			loc = location;
		}
		
		if(isIe6)
		{
			objThis.css('position' , 'absolute');	

			if(loc.left != undefined){
				var left = parseInt(loc.left) - html.scrollLeft();
				domThis.style.setExpression('left', 'eval((document.documentElement).scrollLeft + ' + left + ') + "px"');
			}
			
			if(loc.right != undefined){
				var right = parseInt(loc.right) - html.scrollRight();
				domThis.style.setExpression('right', 'eval((document.documentElement).scrollRight + ' + right + ') + "px"');
			}
			
			if(loc.top != undefined){
				var top = parseInt(loc.top) - html.scrollTop();
				domThis.style.setExpression('top', 'eval((document.documentElement).scrollTop + ' + top + ') + "px"');
			}
			
			if(loc.bottom != undefined){
				var bottom = parseInt(loc.bottom) - html.scrollBottom();
				domThis.style.setExpression('bottom', 'eval((document.documentElement).scrollBottom + ' + bottom + ') + "px"');
			}
		} else {
			objThis.css('position' , 'fixed').css(loc);
		}
			
	});

};


})(jQuery)